package com.webdrider.servlet.util;

import com.common.model.interfaces.IRequestAction;


/**
 * This class contains all the available actions for the project.
 * 
 * @author Ady
 *
 */
public enum RequestAction implements IRequestAction {
	LOGIN, LOGOUT, ADD_USER,
	GET_ALL_SESSIONS,
	ADD_CATEGORY, ADD_BLOG_POST, GET_ALL_CATEGORIES, GET_BLOG_POST,
	GET_ALL_SNIPPET_DOMAINS, ADD_SNIPPET_DOMAIN, ADD_SNIPPET_ARTICLE, GET_ALL_SNIPPET_ARTICLES, SEARCH_SNIPPET_ARTICLES;
	
	public static IRequestAction contains(String action) {
		for (RequestAction requestAction : values()) {
			if (requestAction.equals(action)) {
				return requestAction;
			}
		}
		
		return null;
	}
	
	public boolean equals(String action) {
		action = action.replace(" ", "_");
		return this.toString().equalsIgnoreCase(action);
	}
}